<script setup lang="ts">
  import { onLaunch, onShow, onHide } from '@dcloudio/uni-app';
  import { useAuthStore } from '@/state/modules/auth';
  import { setupInterceptors } from '@/utils/interceptors';
  import { useSysStore } from './state/modules/sys';
  onLaunch(() => {
    console.log('App Launch');
    setupInterceptors();
    const sysStore = useSysStore();

    uni.getSystemInfo({
      success: function (e: any) {
        // #ifndef MP
        // Vue.prototype.StatusBar = e.statusBarHeight;
        // if (e.platform == 'android') {
        // 	Vue.prototype.CustomBar = e.statusBarHeight + 50;
        // } else {
        // 	Vue.prototype.CustomBar = e.statusBarHeight + 45;
        // };
        // #endif

        // #ifdef MP-WEIXIN | H5
        sysStore.setStatusBar(e.statusBarHeight);
        // #endif

        // #ifdef MP-WEIXIN
        const btnPosi = uni.getMenuButtonBoundingClientRect();
        const height = btnPosi.height + (btnPosi.top - e?.statusBarHeight) * 2 + e?.statusBarHeight;
        sysStore.setCustomBar(height);
        // #endif

        // #ifdef MP-ALIPAY
        // #endif
      },
    });
  });
  onShow(() => {
    const authStore = useAuthStore();
    authStore.initToken();
    console.log('App Show');
  });
  onHide(() => {
    console.log('App Hide');
  });
</script>
<style lang="scss">
  /* @import '@/uni_modules/uview-plus/index.scss'; */
  @import 'uview-plus/index.scss';

  page {
    background-color: #f2f2f2;
  }
</style>
